package com.lj.universalframework.dialog

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.lj.universalframework.R

class BottomDialogFragment01 : BottomSheetDialogFragment() {


    companion object {
        @Volatile
        private var instance: BottomDialogFragment01? = null

        fun getInstance() = instance ?: synchronized(this) {
                instance ?: BottomDialogFragment01().also {
                    instance = it
                }
            }
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.dottom_frggment_dialog, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        view.findViewById<TextView>(R.id.tv_shut_down).apply {
            setOnClickListener {
                dismiss()
            }
        }
    }

    override fun onStart() {
        super.onStart()
        //设置透明背景
        dialog!!.window!!.findViewById<View>(R.id.design_bottom_sheet)
            .setBackgroundResource(android.R.color.transparent)
    }

    override fun getTheme(): Int = arguments?.getInt("SheetSelection:ARGS_THEME") ?: super.getTheme()
}